﻿using System.Runtime.Serialization;
using GMME.Model.Rtm.Req;
using UnityEngine;
using UnityEngine.Scripting;

namespace GMME.Model.Rtm.Result
{
    [DataContract]
    public class PublishRtmPeerMessageResult : ErrorResult
    {
        [DataMember(Name = "peerId")]
        [Preserve]
        public string PeerId { get; set; }

        [DataMember(Name = "clientMsgId")]
        [Preserve]
        public string ClientMsgId { get; set; }

        [DataMember(Name = "serverMsgId")]
        [Preserve]
        public string ServerMsgId { get; set; }

        [DataMember(Name = "request")]
        [Preserve]
        public PublishRtmPeerMessageReq Request { get; set; }

#if UNITY_ANDROID
        internal static PublishRtmPeerMessageResult ConvertPublishRtmPeerMessageResult(AndroidJavaObject javaObject)
        {
            if (javaObject != null)
            {
                var result = new PublishRtmPeerMessageResult();
                result.PeerId = javaObject.Call<string>("getPeerId");
                result.ClientMsgId = javaObject.Call<string>("getClientMsgId");
                result.ServerMsgId = javaObject.Call<string>("getServerMsgId");
                result.Code = javaObject.Call<int>("getCode");
                result.Msg = javaObject.Call<string>("getMsg");
                return result;
            }

            return null;
        }
#endif
    }
}